package com.tbit.uqbike.webmanager.business.brandshare.controller;

import com.tbit.common.constant.MethodEnum;
import com.tbit.common.constant.ModuleEnum;
import com.tbit.common.entity.view.Result;
import com.tbit.uqbike.annos.OperateLog;
import com.tbit.uqbike.webmanager.business.brandshare.pojo.BrandShareConfig;
import com.tbit.uqbike.webmanager.business.brandshare.pojo.vo.BrandShareConfigAddVO;
import com.tbit.uqbike.webmanager.business.brandshare.pojo.vo.BrandShareConfigUpdateVO;
import com.tbit.uqbike.webmanager.business.brandshare.pojo.vo.BrandShareListReqVo;
import com.tbit.uqbike.webmanager.business.brandshare.service.BrandShareConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 品牌共享配置
 *
 * @author: qiu.longjie
 * @create: 2025-05-19
 */
@RestController
@RequestMapping("/brandShareConfig")
public class BrandShareConfigController {

    @Autowired
    private BrandShareConfigService brandShareConfigService;

    /**
     * 列表查询
     *
     * @param reqVo 查询条件
     * @return
     */
    @GetMapping("/list")
    public Result<List<BrandShareConfig>> list(BrandShareListReqVo reqVo) {
        return Result.success(brandShareConfigService.queryList(reqVo));
    }

    /**
     * 新增配置
     *
     * @param brandShareConfigVO 配置信息
     * @return
     */
    @PutMapping("/add")
    @OperateLog(module = ModuleEnum.BRAND_SHARE_CONFIG, methods = MethodEnum.BRAND_SHARE_CONFIG_ADD)
    public Result<String> add(@Validated @RequestBody BrandShareConfigAddVO brandShareConfigVO) {
        brandShareConfigService.addConfig(brandShareConfigVO);
        return Result.success();
    }

    /**
     * 更新配置
     *
     * @param brandShareConfigVO 配置信息
     * @return
     */
    @PostMapping("/update")
    @OperateLog(module = ModuleEnum.BRAND_SHARE_CONFIG, methods = MethodEnum.BRAND_SHARE_CONFIG_UPDATE)
    public Result<String> update(@Validated @RequestBody BrandShareConfigUpdateVO brandShareConfigVO) {
        brandShareConfigService.updateConfig(brandShareConfigVO);
        return Result.success();
    }

    /**
     * 删除配置
     *
     * @param id 配置id
     * @return
     */
    @DeleteMapping("/delete")
    @OperateLog(module = ModuleEnum.BRAND_SHARE_CONFIG, methods = MethodEnum.BRAND_SHARE_CONFIG_DELETE)
    public Result<String> delete(Integer id) {
        brandShareConfigService.deleteConfig(id);
        return Result.success();
    }
}
